<template>
	<view class="page">
		<view class="top-bar">
			<view class="top-bar__placeholder" :style="{height: `${statusBarHeight}px`}"></view>
			<view class="top-bar__content">
				<view class="left-icon" @click="goBack()">
					<u-icon name="arrow-left" :size="20" color="#232832"></u-icon>
				</view>
				<view class="title" :style="{maxWidth: `${titleWidth}px`}">
					{{ title }}
				</view>
			</view>
		</view>
		<c-content :top="statusBarHeight + 44">
			<view class="card" v-for="i in 10" :key="i">
				<view class="card-header" @click.stop="goUser()">
					<view class="card-header__icon">
						<u-avatar src="/static/1.png" :size="44"></u-avatar>
					</view>
					<view class="card-header__title">
						<view class="header-title">用户名</view>
						<view class="header-label">合肥市</view>
					</view>
					<view class="card-header__value" @click.self.stop="doAttention()">
						<view class="btn">
							<u-icon name="plus" color="#6E86FF" :size="14" bold></u-icon>
						</view>
					</view>
				</view>
				<view class="card-body" @click.stop="goArticle(i)">
					<view class="card-body__article">
						<u-parse>
							dasdasddddddddddd
							asdaaaaaaaaaa
							asdasssssssssssssssss
							2131231
						</u-parse>
					</view>
					<view class="card-body__album" @click.self.stop>
						<u-album :urls="list" :maxCount="9" borderRadius="8px" :multipleSize="boxWidth"></u-album>
					</view>
					<view class="card-body__video">

					</view>
				</view>
				<view class="card-footer">
					<view class="card-footer__data">
						<view>
							<text class="icon-thumb"></text>
							<text class="value">123</text>
						</view>
						<view>
							<text class="icon-comment"></text>
							<text class="value">123</text>
						</view>
						<view>
							<text class="icon-view"></text>
							<text class="value">123</text>
						</view>
					</view>
				</view>
			</view>
			<view class="placeholder-bar-bottom"></view>
		</c-content>
	</view>
</template>

<script>
	import mixins from '@/mixins/index.js'
	export default {
		mixins: [mixins],
		data() {
			return {
				title: '',
				list: [
					'https://cdn.uviewui.com/uview/swiper/swiper1.png',
					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
				]
			}
		},
		computed: {
			titleWidth() {
				let width = uni.getSystemInfoSync().windowWidth
				// #ifdef MP-WEIXIN
				const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
				width = menuButtonInfo.left
				// #endif
				return width - 26 - 20 - 10
			},
			boxWidth() {
				const rs = uni.getSystemInfoSync()
				console.log(rs.windowWidth - 28);
				const width = (rs.windowWidth - 12 - 44) / 3
				return width
			}
		},
		methods: {
			goBack() {
				uni.navigateBack()
			},
			goUser() {
				uni.navigateTo({
					url: '/pages/common/user'
				})
			},
			doAttention() {
				console.log(222);
			},
			goArticle(art) {
				uni.navigateTo({
					url: '/pages/common/article'
				})
			}
		},
		onLoad(options) {
			this.title = options.title
		}
	}
</script>

<style scoped lang="scss">
	.top-bar {

		&__content {
			display: flex;
			align-items: center;
			height: 44px;
		}

		.left-icon {
			padding: 0 13px;
		}

		.title {
			color: #232832;
			font-size: 15px;
			line-height: 20px;
			font-weight: 600;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	}

	.card {
		margin: 20px 12px;
		background-color: #FFFFFF;
		border-radius: 15px;
		padding: 10px;
		box-sizing: border-box;

		.card-header {
			display: flex;
			align-items: center;

			&__title {
				flex: 1;
				margin-left: 10px;
			}

			.header-title {
				color: #232832;
				font-size: 15px;
				font-weight: 700;
				line-height: 18px;
			}

			.header-label {
				margin-top: 3px;
				color: #B9BCC3;
				font-size: 12px;
				line-height: 16px;
				font-weight: 400;
			}

			&__value {

				.btn {
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 4px 14px;
					border-radius: 15px;
					border: 1px solid #6E86FF;
					color: #6E86FF;
					font-weight: 600;
				}
			}
		}

		.card-body {
			display: flex;
			align-items: center;
			flex-direction: column;
			width: 100%;
			margin-top: 0px;
			padding-top: 10px;

			&__article {
				margin: 5px 0 15px;
				color: #232832;
				text-indent: 2em;
			}

			&::v-deep .u-album__row__wrapper {
				border-radius: 4px;
				overflow: hidden;
			}
		}

		.card-footer {
			padding: 10px 0 0;

			&__data {
				display: flex;
				align-items: center;
				justify-content: flex-start;

				&>view {
					display: flex;
					align-items: center;
					margin-right: 14px;
				}

				[class^=icon] {
					color: #787B86;
					font-size: 16px;
				}

				.value {
					margin-left: 8px;
					color: #787B86;
					font-weight: 400;
					font-size: 12px;
					line-height: 14px;
				}
			}
		}
	}
</style>